$(init);

function init(){
	
	$("#pushGrid").jqGrid(
    {
        url : ctx+"/common/extQuery?sqlid=push",
        postData : $("#searchForm").getFormJson(),
        width:(($(window.document).width())-480),
        height:400,
        datatype: "json",    
        colNames : ['标题','推送人','推送时间'],
        colModel : [ 
            {name : "TITLE",index : "TITLE",width : 600,sortable:false,formatter:function(value,options,row){
            	return "<a href=\"javascript:showInfDetail('"+row.ID+"','"+row.TITLE+"')\">"+value+"</a>";
            }}, 
            {name : "NAME",index : "NAME",width : 100,sortable:false}, 
            {name : "PUSHDATE",index : "PUSHDATE",width : 200,sortable:false} 
        ],
        prmNames:{
            rows:"limit"
        },
        jsonReader :{
            root: "message.list",   
            page: "message.pageNumber",   
            total: "message.totalPage",
            records:"message.totalRow"
        },
        loadtext:"<img src='"+ctx+"/static/images/loading.gif'>&nbsp;&nbsp;拼命加载中...",
        rowNum : 10,
        rowList : [ 10, 30, 50 ],
        pager : "#favPager",
        mtype: "POST",
        viewrecords : true,
        sortable:false
     }); 
     
	$("#favGrid").jqGrid(
    {
        url : ctx+"/common/extQuery?sqlid=fav",
        postData : $("#searchForm").getFormJson(),
        width:(($(window.document).width())-480),
        height:400,
        datatype: "json",    
        colNames : ['标题','操作'],
        colModel : [ 
            {name : "TITLE",index : "TITLE",width : 600,sortable:false,formatter:function(value,options,row){
            	var html = "";
            	if(isNew(Date.parse(row.INFODATE.replace(/-/gi,"/")))){
            		html+="<img src='"+ctx+"/static/images/new.png'>";
            	}
            	html += "<a href=\"javascript:showInfDetail('"+row.ID+"','"+row.TITLE+"')\">"+value+"</a>";
            	return html;
            }}, 
        	{name: 'cz', index: 'cz', width: 100, sortable: false, align: "center", title: false, formatter: function (value, options, row) {
                return "<span class='tdcz'>" +
                        "<a title='取消收藏' class='small_btn del' href=\"javascript:delFav('" + row.ID+"');\">取消收藏</a>" +
                        "</span>";
            }}
        ],
        prmNames:{
            rows:"limit"
        },
        jsonReader :{
            root: "message.list",   
            page: "message.pageNumber",   
            total: "message.totalPage",
            records:"message.totalRow"
        },
        loadtext:"<img src='"+ctx+"/static/images/loading.gif'>&nbsp;&nbsp;拼命加载中...",
        rowNum : 10,
        rowList : [ 10, 30, 50 ],
        pager : "#favPager",
        mtype: "POST",
        viewrecords : true,
        sortable:false
     });      
	
	$("#dlmjgGrid").jqGrid(
    {
        url : ctx+"/common/extQuery?sqlid=dlmjg",
        width:(($(window.document).width())-480),
        height:400,
        datatype: "json",    
        colNames : ['类型','热值','本期价格','上期价格','环比','去年同期','同比'],
        colModel : [ 
            {name : "LX",index : "LX",width : 100,sortable:false}, 
            {name : "RZ",index : "RZ",width : 100,sortable:false}, 
            {name : "BQJG",index : "BQJG",width : 100,sortable:false}, 
            {name : "SQJG",index : "SQJG",width : 100,sortable:false}, 
            {name : "HB",index : "HB",width : 100,sortable:false}, 
            {name : "QNTQ",index : "QNTQ",width : 100,sortable:false}, 
            {name : "TB",index : "TB",width : 100,sortable:false}
        ],
        prmNames:{
            rows:"limit"
        },
        jsonReader :{
            root: "message.list",   
            page: "message.pageNumber",   
            total: "message.totalPage",
            records:"message.totalRow"
        },
        loadtext:"<img src='"+ctx+"/static/images/loading.gif'>&nbsp;&nbsp;拼命加载中...",
        rowNum : 100,
        rowList : [ 10, 30, 50 ],
        mtype: "POST",
        viewrecords : true,
        sortable:false
     });
	 
    $("#mtjgzsGrid").jqGrid(
    {
        url : ctx+"/common/extQuery?sqlid=mtjgzs",
        width:(($(window.document).width())-480),
        height:400,
        datatype: "json",    
        colNames : ['指数名称','本期','上期','增减','增幅'],
        colModel : [ 
            {name : "ZSMC",index : "ZSMC",width : 300,sortable:false}, 
            {name : "BQ",index : "BQ",width : 100,sortable:false}, 
            {name : "SQ",index : "SQ",width : 100,sortable:false}, 
            {name : "ZJ",index : "ZJ",width : 100,sortable:false}, 
            {name : "ZF",index : "ZF",width : 100,sortable:false}
        ],
        prmNames:{
            rows:"limit"
        },
        jsonReader :{
            root: "message.list",   
            page: "message.pageNumber",   
            total: "message.totalPage",
            records:"message.totalRow"
        },
        loadtext:"<img src='"+ctx+"/static/images/loading.gif'>&nbsp;&nbsp;拼命加载中...",
        rowNum : 100,
        rowList : [ 10, 30, 50 ],
        mtype: "POST",
        viewrecords : true,
        sortable:false
     });
     
}

function activeGrid(cls,el){
	$("button").removeClass("_masterbtn").addClass("_btn");
	$(el).addClass("_masterbtn");
	$(".gridDiv").hide();
	$("#"+cls+"Div").show();
	$("#"+cls+"Grid").trigger("reloadGrid",[{page:1}]);
}

function refreshGrid(){
	$("#favGrid").trigger("reloadGrid",[{page:1}]);
}